package model;

import connectivity.QueryManager;
import main.BarApplication;

public class Product {

    private int productId;
    private int categorieId;
    private String name;
    private String description;
    private double price;
    private int cursusId;
    private int vestigingId;
    private int studioId;
    private String cDag;
    private String cTijd;
    private String cBeginD;
    private String cEindD;
    private String cVanT;
    private String cTotT;
    private int cMaxA;
    private int cHuidA;
    private double cPrijs;

        
        public void update() {
        QueryManager queryManager = BarApplication.getQueryManager();
        queryManager.UpdateProduct(this);
           
    }

    public void insert() {
        QueryManager queryManager = BarApplication.getQueryManager();
        queryManager.addProduct(this);
    }
    
    public Product() {
        this(-1, -1, "", 0.0);
    }
    public Product(int product_id, int categorie_id, String name, double price) {
        this.productId = product_id;
        this.categorieId = categorie_id;
        this.name = name;
        this.price = price;
    }
    
        public Product(int product_id, int categorie_id, String name, double price, String description) {
        this.productId = product_id;
        this.categorieId = categorie_id;
        this.name = name;
        this.price = price;
        this.description = description;
    }

     // Added new constructor for the Cursus table
    public Product(int idcursusrooster, int productnummer, int idvestiging, int studionummer, String dag, String tijd, String beginD, String eindD, String vanT, String totT, int MaxA, int HuidA, String naam, Double prijs) {
        this.cursusId = idcursusrooster;
        this.productId = productnummer;
        this.vestigingId = idvestiging;
        this.studioId = studionummer;
        this.cDag = dag;
        this.cTijd = tijd;
        this.cBeginD = beginD;
        this.cEindD = eindD;
        this.cVanT = vanT;
        this.cTotT = totT;
        this.cMaxA = MaxA;
        this.cHuidA = HuidA;
        this.name = naam;
        this.cPrijs = prijs;
    }
    
    
    public int getCursusId() {
        return cursusId;
    }

    public void setCursusId(int cursusId) {
        this.cursusId = cursusId;
    }

    public int getVestigingId() {
        return vestigingId;
    }

    public void setVestigingId(int vestigingId) {
        this.vestigingId = vestigingId;
    }

    public int getStudioId() {
        return studioId;
    }

    public void setStudioId(int studioId) {
        this.studioId = studioId;
    }

    public String getcDag() {
        return cDag;
    }

    public void setcDag(String cDag) {
        this.cDag = cDag;
    }

    public String getcTijd() {
        return cTijd;
    }

    public void setcTijd(String cTijd) {
        this.cTijd = cTijd;
    }

    public String getcBeginD() {
        return cBeginD;
    }

    public void setcBeginD(String cBeginD) {
        this.cBeginD = cBeginD;
    }

    public String getcEindD() {
        return cEindD;
    }

    public void setcEindD(String cEindD) {
        this.cEindD = cEindD;
    }

    public String getcVanT() {
        return cVanT;
    }

    public void setcVanT(String cVanT) {
        this.cVanT = cVanT;
    }

    public String getcTotT() {
        return cTotT;
    }

    public void setcTotT(String cTotT) {
        this.cTotT = cTotT;
    }

    public int getcMaxA() {
        return cMaxA;
    }

    public void setcMaxA(int cMaxA) {
        this.cMaxA = cMaxA;
    }

    public int getcHuidA() {
        return cHuidA;
    }

    public void setcHuidA(int cHuidA) {
        this.cHuidA = cHuidA;
    }
    
    public int remainingA(){
        int remaining = this.cMaxA - cHuidA;
        if (remaining < 0){remaining = 0;}
        return remaining;
    }

    public double getcPrijs() {
        return cPrijs;
    }

    public void setcPrijs(double cPrijs) {
        this.cPrijs = cPrijs;
    }

    /**
     * @return the productId
     */
    public int getProductId() {
        return productId;
    }

    /**
     * @param productId the productId to set
     */
    public void setProductId(int productId) {
        this.productId = productId;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the price
     */
    public double getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * @return the categorieId
     */
    public int getCategorieId() {
        return categorieId;
    }

    /**
     * @param categorieId the categorieId to set
     */
    public void setCategorieId(int categorieId) {
        this.categorieId = categorieId;
    }

    @Override
    public String toString() {
        return name;
    }

    @Override
    public boolean equals(Object obj) {
        boolean value;
        if (obj instanceof Product) {
            value = this.productId == ((Product) obj).productId;
        } else {
            value = super.equals(obj);
        }
        return value;
    }

    @Override
    public int hashCode() {
        return 13 * 3 + this.productId;
    }
}
